const express = require("express");
const router = express.Router();

const MySql = require("../lib/mysql");

router.post("/userBasic",async(req,res,next) => {


    //从前端得到的表单内容存入数据库
    const id = req.body.id;
    const name = req.body.name;
    const sex = req.body.sex;
    const phone = req.body.phone;
    const email = req.body.email;
    const specialty = req.body.specialty;
    const college = req.body.college;
    const photourl = req.body.photourl;
    const birthday = req.body.birthday;
    const homeland = req.body.homeland;
    const politic = req.body.politic;
    const nationality = req.body.nationality;
    const skills = req.body.skills;
    const evaluate = req.body.evaluate;
    const others = req.body.others;



   //console.log(id,name,sex,password,phone,email,specialty,college,photourl,birthday,homeland,politic,nationality);
try {
    const resUpdate = await MySql.query('update user set name = ?, sex = ?,phone = ?,email = ?,specialty = ?,college = ?,birthday = ?,homeland=?,politic=?,nationality= ?,skills =?,evaluate =?,others =? where id = ?',[name,sex,phone,email,specialty,college,birthday,homeland,politic,nationality,skills,evaluate,others, id]);

        res.json({
            code:1,
            message:'basic保存成功',
        })
    
} catch (error) {
    console.log(error)
      res.json({
          code: -1,
          message: '服务器错误'
      })
}
        
});

module.exports = router;